package com.text.dao;


import com.text.entity.Category;
import org.apache.ibatis.annotations.*;


import java.util.ArrayList;

@Mapper
public interface CategoryDao {
    @Select("select * from category where id = #{cid}")
    Category queryBytID(Integer cid);

    @Select("select * from category")
    ArrayList<Category> queryAll();

    @Insert("INSERT INTO category" +
            "(`name`)" +
            "VALUES(" +
            " #{category.name}" +
            ")")

    @Options(useGeneratedKeys = true, keyProperty = "category.id")
    int insert(@Param("category") Category category);



    @Select("SELECT * FROM category WHERE id = #{id}")
    Category edit(Integer id);

    @Update("update category SET " +
            " name = #{edit.name}" +
            "  where id = #{edit.id}")
    int update(@Param("edit") Category edit);


    @Delete("delete from category where id = #{id}")
    int deleteById(Integer id);
}
